<%@ page import="java.sql.*" errorPage="" %>
<h1>Tasks Allocated</h1>
<ul class="sidemenu">
    <%//Grab the username and emp_id form of the user
    String uname=(String)session.getAttribute("userName");
    String emp_id=(String)session.getAttribute("emp_id");
    int ei=Integer.parseInt(emp_id);
    %>
    <%
    String query="select task.name,task.task_id from task ,task_division where task_division.emp_id='"+ei+"'"+" and task.task_id=task_division.task_id";
    Connection db_conn = null;
    Statement statement = null;
    PreparedStatement pstmt;
    ResultSet rs;
    try{
    Class.forName("com.mysql.jdbc.Driver");
    String url= "jdbc:mysql://localhost:3306/db";
    db_conn = DriverManager.getConnection( url,"root", "root" );
    statement = db_conn.createStatement();
    rs=statement.executeQuery(query);
    while (rs.next()) { // parse the results
    String tname=rs.getString("task.name");
    String tid=rs.getString("task.task_id");
    out.print("<li><a href='"+"user.jsp?pageid=task&&tid="+tid+"'"+">"+tname+"</a></li>");
    }
    db_conn.close();
    } catch(SQLException e){
    e.printStackTrace();
    out.println("sql not found");
    out.println(e);
    } catch(ClassNotFoundException e){
    e.printStackTrace();
    out.println(e);
    }
    %>
</ul>